package com.hmdp.exception;

import com.hmdp.dto.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)  //可以使用自定义的注解.class
    public Result handleException(Exception ex) {
        return Result.fail(ex.getMessage());
    }

}
